home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Screenblankers / XSB / gtlib.c < prev    next >
C/C++ Source or Header  |  1996-09-26  |  2KB  |  134 lines

  1. /*
  2.     gadtools support lib
  3.  
  4. */
  5.  
  6. #include "startup.h"
  7.  
  8. static struct VisualInfo *vi;
  9. static struct Gadget *glist,*lastg,*gads[32];
  10. static int gid;
  11. struct TextAttr textattr={"topaz.font",8,0,0};
  12. #define top80 textattr
  13.  
  14. void gt_init(void)
  15. {
  16.     struct Screen *scr;
  17.     scr=LockPubScreen(0);
  18.     vi=GetVisualInfo(scr,TAG_DONE);
  19.     UnlockPubScreen(0,scr);
  20. }
  21.  
  22. void gt_exit(void)
  23. {
  24.     if(vi) FreeVisualInfo(vi);
  25. }
  26.  
  27. struct Gadget *gt_newlist(void)
  28. {
  29.     glist=0;gid=1;
  30.     lastg=CreateContext(&glist);
  31.     return(lastg);
  32. }
  33.  
  34. void gt_endlist(void)
  35. {
  36.     AddGList(w,glist,-1,-1,0);
  37.     RefreshGList(glist,w,0,-1);
  38.     GT_RefreshWindow(w,0);
  39. }
  40.  
  41. void gt_remlist(struct Gadget *list)
  42. {
  43.     FreeGadgets(list);
  44. }
  45.  
  46. struct Gadget * __stdargs gt_createg(int x,int y,int xs,int ys,long type,char *label,int flags,...)
  47. {
  48.     struct NewGadget ng;
  49.  
  50.     ng.ng_LeftEdge=x; ng.ng_TopEdge=y;
  51.     ng.ng_Width=xs; ng.ng_Height=ys;
  52.     ng.ng_GadgetText=label;
  53.     ng.ng_GadgetID=gid++;
  54.     ng.ng_TextAttr=&top80;
  55.     ng.ng_Flags=flags;
  56.     ng.ng_VisualInfo=vi;
  57.     ng.ng_UserData=(APTR)0xaffe;
  58.  
  59.     return(lastg=gads[gid-2]=CreateGadgetA(type,lastg,&ng,((long)(&flags))+4));
  60. }
  61.  
  62. void gt_setg(struct Gadget *g,...)
  63. {
  64.     GT_SetGadgetAttrsA(g,w,0,((long)(&g))+4);
  65. }
  66.  
  67. void gt_drawbox(int x,int y,int size,int height,int typ)
  68. {
  69.     DrawBevelBox(rp,x,y,size,height,(typ)?TAG_IGNORE:GTBB_Recessed,0,GT_VisualInfo,vi,TAG_DONE);
  70. }
  71.  
  72. /*struct Menu *gt_createmenus(struct NewMenu *nm)
  73. {
  74.     struct Menu *m;
  75.  
  76.     m=CreateMenus(nm,GTMN_FrontPen,0,TAG_DONE);
  77.     if(m) {
  78.         if(LayoutMenus(m,vi,GTMN_TextAttr,&top80,TAG_DONE)) return(m);
  79.         FreeMenus(m);
  80.     }
  81.     return(0);
  82. }*/
  83.  
  84. int doreq(char *hail,char *txt,char *gads,...)
  85. {
  86.     struct EasyStruct es;
  87.  
  88.     es.es_StructSize=sizeof(struct EasyStruct);
  89.     es.es_Flags=0;
  90.     es.es_Title=hail;
  91.     es.es_TextFormat=txt;
  92.     es.es_GadgetFormat=gads;
  93.     return(EasyRequestArgs(w,&es,0,((long)&gads)+4));
  94. }
  95.  
  96. void text(int x,int y,char *txt)
  97. {
  98.     Move(rp,x,y);
  99.     Text(rp,txt,strlen(txt));
  100. }
  101.  
  102. void textf(int x,int y,char *txt,...)
  103. {
  104.     char p[128];
  105.  
  106.     _dofmt(txt,((long)&txt)+4,p);
  107.     Move(rp,x,y);
  108.     Text(rp,&p[0],strlen(&p[0]));
  109. }
  110. struct Gadget *gt_findid(short id)
  111. {
  112.     if(!id) return(0);
  113.     return(gads[id-1]);
  114. }
  115.  
  116. char *gt_findstring(short id)
  117. {
  118.     struct StringInfo *si=gt_findid(id)->SpecialInfo;
  119.  
  120.     return(si->Buffer);
  121. }
  122.  
  123. long gt_findint(short id)
  124. {
  125.     struct StringInfo *si=gt_findid(id)->SpecialInfo;
  126.  
  127.     return(si->LongInt);
  128. }
  129.  
  130. int gt_findstate(short id)
  131. {
  132.     return(gt_findid(id)->Flags&SELECTED);
  133. }
  134.